//
//  RootView.m
//  UI4_Delegate课后作业轻拍返回键盘
//
//  Created by dllo on 15/11/11.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "RootView.h"

@interface RootView ()<UITextFieldDelegate>

@end

@implementation RootView

- (void)dealloc
{
    [_label release];
    [_textF release];
    [_tapGR release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self createSubviews];
    }
    return self;
}


- (void)createSubviews
{
    self.backgroundColor = [UIColor whiteColor];
    self.label = [[UILabel alloc] initWithFrame:CGRectMake(80, 200, 60, 30)];
    [self addSubview:self.label];
    [_label release];
    
    self.textF = [[UITextField alloc] initWithFrame:CGRectMake(self.label.frame.origin.x + self.label.frame.size.width, 200, 150, 30)];
    self.textF.clearButtonMode = UITextFieldViewModeAlways;
    self.textF.borderStyle = UITextBorderStyleRoundedRect;
    self.textF.delegate = self;
    [self addSubview:self.textF];
    [_textF release];

        self.tapGR = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)];
    [self addGestureRecognizer:self.tapGR];
        [_tapGR release];


}

- (void)tapAction:(UITapGestureRecognizer *)sender
{
    [self.textF resignFirstResponder];
}

- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [textField resignFirstResponder];
    return YES;
}




@end
